<h1 class="crayons-title mb-6">Admin roles</h1>

<%= paginate @users %>

<table class="crayons-table" width="100%">
  <thead>
    <tr>
      <th scope="col">ID</th>
      <th scope="col">Profile</th>
      <th scope="col">Roles</th>
    </tr>
  </thead>
  <tbody class="crayons-card">
    <% @users.each do |user| %>
      <tr>
        <td class="align-top whitespace-nowrap"><%= user.id %></td>
        <td class="align-top"><%= link_to "@#{user.username}", user.path %></td>
        <td>
          <ul>
            <% user.roles.pluck(:name, :resource_type, :resource_id).each do |role| %>
              <li><%= role[0] %><%= ": #{role[1]}" if role[1] %><%= "/#{role[2]}" if role[2] %></li>
            <% end %>
          </ul>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>

<%= paginate @users %>
